package WebServices;

import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.commons.httpclient.*;

import java.rmi.RemoteException;
import javax.xml.rpc. ServiceException;

//import PHPWebServices.StockHospitalsService;
//import PHPWebServices.StockHospitalsServiceLocator;
//import PHPWebServices.StockHospitalsPortType;
//	import PHPWebServices.StockHospitalsBindingStub;

import javax.xml.namespace.QName;

public class KSNetContext
{
   public static void main(String [] args) 
   {
	   if ( 2 == 1 )
	   {
		   /*
		   try
		   {
			   //StockHospitalsService phpStockHospitalsService = new StockHospitalsServiceLocator(  );
			   //System.out.println( "1" );
			   //StockHospitalsPortType dis = phpStockHospitalsService.getStockHospitalsPort();
			   //System.out.println( "2"  + phpStockHospitalsService.getStockHospitalsPortAddress());
			   //String ret = dis.getHospitals();
			   //System.out.println( "3" );
			   //System.out.println( ret );
		   }
		   catch ( RemoteException ex)
			{
				System.err.println( ex.toString() );
			}
			catch ( ServiceException ex )
			{
				System.err.println(ex.toString());
			}
			*/
	   }
	   else System.out.println( new KSNetContext().takeAll() );

		   
   }
   
   String takeAll()
   {
	   String sRes = ""; 
	   String sEndPoint;
	   
	   HttpClient client = new HttpClient();
	   
       try {
    	   
    	   //	sEndPoint = "http://www.cbr.ru/DailyInfoWebServ/DailyInfo.asmx?wsdl";
           //	callAux.setOperationName( new QName( "http://web.cbr.ru/", ">GetCursOnDate" ) );
    	   
           //sEndPoint = "http://192.168.0.102/scripts/SOAP/test.wsdl";
    	   
           sEndPoint = "http://192.168.0.101/ksnet2/HospitalService/s.wsdl?";
           //	sEndPoint = "http://192.168.0.101:8080/axis/Solver/WebServiceSolver.jws?wsdl";
           
           //	sEndPoint = "http://195.201.73.101/ksnet2/HospitalService/server.wsdl";
           
           //sEndPoint = "http://192.168.0.101/ksnet2/WeatherService/server.wsdl";
    	   
    	   //	sEndPoint = "http://chs.gotdotnet.com/quickstart/aspplus/samples/services/MathService/VB/MathService.asmx?wsdl";
     
           Service  srvcAux = new Service();
           Call callAux = ( Call )srvcAux.createCall();
           

           callAux.setTargetEndpointAddress( new java.net.URL( sEndPoint ) );
           //	callAux.setOperationName(new QName( "GetLatestDate" ) );
           //	callAux.setOperationName(new QName( "getTemperature" ) );
           callAux.setOperationName( new QName( "getHospital" ) );
           //	callAux.setOperationName( new QName( "runTest" ) );
           
           /*
           callAux.setOperationName( new QName( "Add" ) );
           callAux.setProperty(callAux.SOAPACTION_USE_PROPERTY, new Boolean(true));
           callAux.setProperty(callAux.SOAPACTION_URI_PROPERTY,"http://tempuri.org/Multiply");

           callAux.addParameter("A",org.apache.axis.encoding.XMLType.XSD_FLOAT,javax.xml.rpc.ParameterMode.IN );
           callAux.addParameter("B",org.apache.axis.encoding.XMLType.XSD_FLOAT,javax.xml.rpc.ParameterMode.IN );
           callAux.setReturnType( org.apache.axis.encoding.XMLType.XSD_FLOAT);
           Float ret = (Float)callAux.invoke(new Object[] { new Float( 2 ), new Float( 2 ) });
           */

           sRes = (String) callAux.invoke(new Object[] {  } );
           
           //	System.out.println( callAux.getSOAPActionURI() );

           //	System.out.println( "got '" + ret + "'");
           
       } catch (Exception e) {
           System.err.println(e.toString());
       }
       return sRes;
   }
}

/*
org.apache.axis.description.OperationDesc operAux = new org.apache.axis.description.OperationDesc();
operAux.setName("GetCursOnDate");
org.apache.axis.description.ParameterDesc paramAux = 
	   new org.apache.axis.description.ParameterDesc( 
			   new javax.xml.namespace.QName( 
					   "http://web.cbr.ru/", 
					   "On_date"
			   ), 
			   org.apache.axis.description.ParameterDesc.IN, 
			   new javax.xml.namespace.QName(
					   "http://www.w3.org/2001/XMLSchema", 
					   "dateTime"
			   ), 
			   java.util.Calendar.class, 
			   false, 
			   false
			);
operAux.setReturnType( new javax.xml.namespace.QName("http://web.cbr.ru/", ">>GetCursOnDateResponse>GetCursOnDateResult" ));
operAux.setReturnClass(ru.cbr.web.GetCursOnDateResponseGetCursOnDateResult.class);
operAux.setReturnQName(new javax.xml.namespace.QName("http://web.cbr.ru/", "GetCursOnDateResult"));
*/

/*
 * import ru.cbr.web.DailyInfo;
import ru.cbr.web.DailyInfoLocator;
import ru.cbr.web.DailyInfoSoap;
import ru.cbr.web.GetCursOnDateResponseGetCursOnDateResult;


StockHospitalsService  = new DailyInfoLocator(  );
DailyInfoSoap dis = di.getDailyInfoSoap();
//	float ret = dis.getCursOnDate( calDate );
String ret = dis.getLatestDate( );
System.out.println( ret );

GetCursOnDateResponseGetCursOnDateResult res = dis.getCursOnDate( calDate );
System.out.println( "Length: " + res.get_any().length );
System.out.println( "0: " + res.get_any()[0] );
System.out.println( "1: " + res.get_any()[1] );

*/